<?php
class ourDate
{
	/*******************************************************************
	 * current date functions
	 * these will return the 'current' date, in different formats
	 * current date must always by in 'YY-mm-dd HH:MM:SS' format
	 ****************************************************************/
	/* 
	 * returns the current date
	 */
	private static function getDate()
	{
		return '2011-12-05 8:00:00';
	}
	/*
	 * returns a string of the current date
	 */
	public static function getDateString()
	{
		return date(ourDate::getDate());
	}
	/*
	 * returns the sql format of the current date
	 */
	public static function getDateSQL()
	{
		return strtotime(ourDate::getDate());
	}
	
	
	/**************************************************
	 * other date functions
	 * these take in a date and format it differently
	 **************************************************/
	/*
	 * this is the common date format for the site
	 * 
	 * it takes an event input string of date
	 * if the event date is equal to the current date, it will output "Today 5pm"
	 * if the event date is tomorrow, it will output "Tomorrow 5pm"
	 * if the event date is any other date, then it will output "Dec 6 @ 5:30pm"
	 */
	static function formatDate($date)
	{
		$eventDate = strtotime($date);
		$currentDateString = ourDate::getDateString();
		$currentDate = strtotime($currentDateString);
		$formattedDate = 'error with date';
		
		//check if event date is equal to current date
		if( date('Y-m-d', $currentDate) == date('Y-m-d', $eventDate)  )
		{
			if( date('i', $eventDate) == date('i', strtotime('00:00:00')) )
				$formattedDate = "Today ".date("ga", $eventDate);
			else
				$formattedDate = "Today ".date("g:ia", $eventDate);
		}
		
		//check if event date is tomorrow
		elseif( date('Y-m-d', strtotime("+1 days", $currentDate)) == date('Y-m-d', $eventDate) )
		{
			if( date('i', $eventDate) == date('i', strtotime('00:00:00')) )
				$formattedDate = "Tomorrow ".date("ga", $eventDate);
			else
				$formattedDate = "Tomorrow ".date("g:ia", $eventDate);
		}
		
		//else output formatted date
		else 
		{
			if( date('i', $eventDate) == date('i', strtotime('00:00:00')) )
				$formattedDate = date("M j @ ga", $eventDate);
			else
				$formattedDate = date("M j @ g:ia", $eventDate);
		}
		
		return $formattedDate;
	}
}
?>